package com.oasys.controller;

import com.oasys.entity.po.DeptPo;
import com.oasys.entity.vo.DeptVo;
import com.oasys.service.DeptService;
import com.oasys.utils.ResponseResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2022/5/15
 **/
@RestController
@RequestMapping("/deptInfo")
@Slf4j
@Api("部门管理")
public class DeptController {

    @Resource
    private DeptService deptService;

    /**
     * get
     * @param deptVo
     * @return
     */
    @PostMapping("/getDeptInfo")
    public ResponseResult<Map<String,Object>> getDeptInfo(@RequestBody DeptVo deptVo){
        return deptService.getDeptInfo(deptVo);
    }

    /**
     * add
     * @param deptName
     * @return
     */
    @PostMapping("/addDept")
    public ResponseResult<Boolean> addDept(String deptName){
        return deptService.addDept(deptName);
    }

    /**
     * update
     * @param deptPo
     * @return
     */
    @PostMapping("/updateDept")
    public ResponseResult<Boolean> updateDept(@RequestBody DeptPo deptPo){
        return deptService.updateDept(deptPo);
    }

    /**
     * del
     * @param deptId
     * @return
     */
    @GetMapping("/delDept/{deptId}")
    public ResponseResult<Boolean> delDept(@PathVariable("deptId") String deptId){
        return deptService.delDept(Long.parseLong(deptId));
    }

}
